/**
 * Created by aixin on 2018/12/12.
 */
import Vue from 'vue';
Vue.filter('fetchOptions', function (deptList) {
    let options = getOptions(deptList);
    return options;
});

function getOptions (deptList) {
    for (let i = 0; i < deptList.length; i++) {
        deptList[i].value = deptList[i].id;
        deptList[i].label = deptList[i].text;
        if (Array.isArray(deptList[i].children) && JSON.stringify(deptList[i].children) === '[]') {
            delete deptList[i].children;
        } else {
            getOptions(deptList[i].children);
        }
    }
    return deptList;
}

Vue.filter('dictionType', type => {
    switch (type) {
    case '1':
        type = '国家标准';
        break;
    case '2':
        type = '地方标准';
        break;
    case '3':
        type = '行业标准';
        break;
    default:
        type = '无';
        break;
    }
    return type;
});

Vue.filter('systemType', type => {
    switch (type) {
    case '1':
        type = '大数据处理';
        break;
    case '2':
        type = '大数据支撑';
        break;
    case '3':
        type = '大数据共享交换';
        break;
    case '4':
        type = '大数据服务';
        break;
    case '5':
        type = '大数据治理';
        break;
    }
    return type;
});

Vue.filter('menuType', type => {
    switch (type) {
    case 1:
        type = '目录';
        break;
    case 2:
        type = '菜单';
        break;
    case 3:
        type = '按钮';
        break;
    }
    return type;
});
